package bat.iog.hytool.pattern.behavioral.strategy.demo2;

public class StrategyDemo {
    public static void main(String[] args) {
        Context context = new Context(new StrategyA());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        context = new Context(new StrategyB());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));
    }
}

class Context{
    
    private Strategy strategy;

    public Context(Strategy strategy){
        this.strategy = strategy;
    }

    public int executeStrategy(int num1, int num2){
        return strategy.doOperation(num1, num2);
    }
    
}

interface Strategy{
    public int doOperation(int num1, int num2);
}

class StrategyA implements Strategy {

    @Override
    public int doOperation(int num1, int num2) {
        return 0;
    }
}

class StrategyB implements Strategy {

    @Override
    public int doOperation(int num1, int num2) {
        return 0;
    }
}